*******************
**** Figure 10 ****
*******************


use "$data/stickerpromptsurvey" , clear



** Data prep **
gen manipulation=0 if q1a==1 // People who see sticker for the first time vs saw sticker at home 
replace manipulation=1 if q1a==2

gen q2bALT=q2b
replace q2bALT=4 if identitylabel==0 & manipulation==0 // This corrects for the fact that people who saw a basic sticker at home cannot recall an identity appeal sticker. 6549/9842 = 0,6645% received an identity appeal 

foreach var in q2a q2bALT q2c q2d {
gen bar`var'=0 if `var'!=.
replace bar`var'=1 if `var'<3 & `var'!=.
}

foreach var in q5a q5b q5c q5d q5e {
gen bar`var'=0 if `var'!=.
replace bar`var'=1 if `var'<2 & `var'!=.
}





** self predictions **
tab q3 identitylabel if q1a!=2 & identitylabel!=1, chi col // They think the PIDAS are more encouraging
tab q3 identitylabel if q1a!=2 & identitylabel!=2, chi col //  They think the NIDAS are more encouraging






* Acceptability of stickers **
tab barq5a manipulation, chi
tab barq5b manipulation, chi
tab barq5c manipulation, chi
tab barq5d manipulation, chi
tab barq5e manipulation, chi


preserve
collapse (mean) barq2a barq2bALT barq2c barq2d barq5a barq5b barq5c barq5d barq5e (sebinomial) sebarq2a=barq2a sebarq2bALT=barq2b sebarq2c=barq2c sebarq2d=barq2d sebarq5a=barq5a sebarq5b=barq5b sebarq5c=barq5c sebarq5d=barq5d sebarq5e=barq5e,  by(manipulation)

*replace barq2b=barq2b/0.6645 /// corrects for the fact that untreated customers cannot remember sticker?


foreach var of varlist barq2a barq2bALT barq2c barq2d barq5a barq5b barq5c barq5d barq5e {
gen lb`var'=`var'-se`var'
gen ub`var'=`var'+se`var'
}

gen t1=1 if barq2a!=.
gen t2=1 if barq2bALT!=.
gen t3=1 if barq2c!=.
gen t4=1 if barq2d!=.

gen z1=1 if barq5a!=.
gen z2=1 if barq5b!=.
gen z3=1 if barq5c!=.
gen z4=1 if barq5d!=.
gen z5=1 if barq5e!=.

gen manipulation2=manipulation+2.5 
gen manipulation3=manipulation+5
gen manipulation4=manipulation+7.5
gen manipulation5=manipulation+10



	   
twoway (bar barq5a manipulation if z1==1, color(gs8) barwidth(0.95) bargap(2)) (rcap lbbarq5a ubbarq5a manipulation, lcolor(black)) ///
       (bar barq5b manipulation2 if z2==1, color(gs8) barwidth(0.95)) (rcap lbbarq5b ubbarq5b manipulation2, lcolor(black)) ///
       (bar barq5c manipulation3 if z3==1, color(gs8) barwidth(0.95)) (rcap lbbarq5c ubbarq5c manipulation3, lcolor(black)) ///
       (bar barq5d manipulation4 if z4==1, color(gs8) barwidth(0.95)) (rcap lbbarq5d ubbarq5d manipulation4, lcolor(black)) ///
	   (bar barq5e manipulation5 if z5==1, color(gs8) barwidth(0.95)) (rcap lbbarq5e ubbarq5e manipulation5, lcolor(black)) ///
	   , yla (0(0.1)0.9) xlabel(0.5 "Useful and good" 3 "Encouraging" 5.5 "Informative" 8 "Demanding/offending" 10.5 "Cautioning", noticks labsize(small)) ytitle("Fraction that fully agrees", size(msmall)) legend(row(1) order(1 "Untreated (not seen before)" 3 "Treated (seen at home)") )graphregion(color(white)) title("Impression of the sticker", color(black))


graph export "$filepath/output_logs/figure 10.pdf", replace

